;;; deno-repl-options.el
;;; Version - 1.0.0
;;; Author - Nalin Ranjan

(require 'comint)
(require 'deno-repl-options)

;; (defvar deno-repl-mode nil "")

(defconst deno-repl-buffer-name "deno-repl")
(defconst deno-repl-mode-name "deno/repl")

(defvar deno-repl-mode-map
  (let ((repl-key-map (nconc
	      (make-sparse-keymap)
	      comint-mode-map)))
    ;; example definition
    (define-key repl-key-map "\t" 'completion-at-point)
    repl-key-map)
  "Basic mode map for `deno-repl-mode'")


(define-derived-mode deno-repl-mode comint-mode
  deno-repl-mode-name
  "A major mode for deno repl"
  :group 'deno
  )

(defun deno-repl ()
  "command to launch a deno repl"
  (interactive)

  (let*
      ((repl-buffer (get-buffer-create deno-repl-buffer-name)))

    (with-current-buffer repl-buffer
      (deno-repl-mode)
      ;; (set major-mode 'deno-repl-mode)
      (goto-char (point-max))
      ;; (insert "Hello! We are making such a good progress!!!")
      )
    
    (switch-to-buffer repl-buffer)))

(let
    ((repl-options (make-deno-repl-options
		    ;; :config "  "
		    ;; :log-level "      "
		    ;; :lock " asdf"
		    ;; :cert "asdf "
		    ;; :eval "console.log(\"Hello\") "
		    ;; :import-map " tu hai wahi "
		    ;; :location " href "
		    ;; :cached-only t
		    ;; :compat t
		    ;; :help t
		    ;; :lock-write t
		    ;; :no-remote t
		    ;; :quiet t
		    ;; :unstable t
		    ;; :seed 123
		    )))
  (deno-repl-command repl-options)
  ;; (run-deno-repl
  ;;  (deno-repl-command repl-options))
  )



(provide 'deno-repl)
